﻿// ChaosKitInterface code
// Author: Scientio LLC. http://www.scientio.com
// The web service to which this code refers is copyright 2009 Scientio LLC, all rights reserved.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace Scientio.WebServices
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://www.scientio.com/ChaosAnalysisService/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class ChaosKit : System.Web.Services.WebService
    {

 
        /// <summary>
        /// Constructor
        /// </summary>
        public ChaosKit()
        {
        }


        /// <summary>
        /// Add a single time-tagged sample to the temporal database.
        /// </summary>
        /// <remarks>Samples can be added in any order.</remarks>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to add data to.</param>
        /// <param name="Value">The value to add</param>
        /// <param name="TimeStamp">The time stamp associated with that value.</param>
        /// <remarks>The maximum size of a time series is limited. If you exceed the limit then samples will be removed from the start of the series, i.e. the earliest samples. If this sample precedes the other values in the time series, this value may be removed as part of this process.</remarks>
        [WebMethod(Description = "Add a single time-tagged sample to the temporal database.")]
        public void AddSample(string UserID, string SeriesID, double Value, DateTime TimeStamp)
        {
        }




        /// <summary>
        /// Add a set of time-tagged samples to the temporal database, encoded in XML.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to add data to.</param>
        /// <param name="Data">The data to load, encoded as well-formed XML.</param>
        /// <param name="SamplePath">The XPath statement required to access sample nodes.</param>
        /// <param name="ValuePath">The XPath statement required to access the value, relative to the sample node.</param>
        /// <param name="TimeStampPath">The XPath statement required to access the timestamp, relative to the sample node.</param>
        /// <remarks>The maximum size of a time series is limited. If you exceed the limit then samples will be removed from the start of the series, i.e. the earliest samples. This will overwrite existing data in the series.</remarks>
        [WebMethod(Description = "Add a set of time-tagged samples to the temporal database, encoded in XML.")]
        public void AddTimeStampedSeriesData(string UserID, string SeriesID, string Data, string SamplePath, string ValuePath, string TimeStampPath)
        {

        }
        /// <summary>
        /// Add a set of regularly spaced samples to the temporal database, encoded in XML.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to add data to.</param>
        /// <param name="Data">The data to load, encoded as well-formed XML.</param>
        /// <param name="SamplePath">The XPath statement required to access sample nodes.</param>
        /// <param name="ValuePath">The XPath statement required to access the value, relative to the sample node.</param>
        /// <param name="StartTime">The time tag for the first data value in document order.</param>
        /// <param name="SampleTime">The regular time interval separating subsequent data values in document order.</param>
        /// <returns>The number of samples stored.</returns>
        /// <remarks>The maximum size of a time series is limited. If you exceed the limit then samples will be removed from the start of the series, i.e. the earliest samples. This will overwrite existing data in the series.</remarks>
        [WebMethod(Description = "Add a set of regularly spaced samples to the temporal database, encoded in XML.")]
        public int AddSampledSeriesData(string UserID, string SeriesID, string Data, string SamplePath, string ValuePath, DateTime StartTime, string SampleTime)
        {
            int result = 0;
            return result;
        }

        /// <summary>
        /// Get the time of the latest sample in this time series.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series</param>
        /// <returns>The time stamp of the last sample</returns>
        [WebMethod(Description = "Get the time of the latest sample in this time series.")]
        public DateTime GetLastSampleTime(string UserID, string SeriesID)
        {
            return DateTime.MinValue;
        }
        /// <summary>
        /// Get the time of the earliest sample in this time series.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series</param>
        /// <returns></returns>
        [WebMethod(Description = "Get the time of the earliest  sample in this time series.")]
        public DateTime GetFirstSampleTime(string UserID, string SeriesID)
        {
            return DateTime.MaxValue;
        }

        /// <summary>
        /// Gets the actual data used in analysis, resampled and respecting trading times, granularity and attention span.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series</param>
        /// <returns>The sampled values as doubles.</returns>
        /// <remarks>To save bandwidth only the most recent 1000 samples will be returned.</remarks>
        [WebMethod(Description = "Gets the actual data used in analysis, resampled and respecting trading times, granularity and attention span.")]
        public double[] GetSeriesSampledData(string UserID, string SeriesID)
        {
            List<double> list = new List<double>();
            return list.ToArray();
        }

        /// <summary>
        /// Create a new time series, specifying its properties, and retrieve its ID.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="TradingTimesID">The ID of a Trading times object if required, empty otherwise</param>
        /// <param name="SampleTime">The default sample time for the time series</param>
        /// <param name="Differencing">If true the difference between subsequent samples is used in the analysis, rather than the values themselves.</param>
        /// <param name="DeadPeriod">If a gap greater than this is encountered in processing the time series, the fifos will be cleared and refilled when data starts again. Set to an empty string to disable this feature.</param>
        /// <param name="Interpolation">Determine interpolation. values, "interpolate" or blank. </param>
        /// <param name="Name">A name to identify the time series.</param>
        /// <returns>The unique ID by which this series will subsequently be recognised</returns>
        [WebMethod(Description = "Create a new time series, specifying its properties, and retrieve its ID.")]
        public string CreateTimeSeries(string UserID, string TradingTimesID, string SampleTime, bool Differencing, string DeadPeriod, string Interpolation, string Name)
        {
            return string.Empty;
        }




        /// <summary>
        /// Update the properties of an existing time series.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the series to update</param>
        /// <param name="TradingTimesID">The ID of a Trading times object if required, empty otherwise</param>
        /// <param name="SampleTime">The default sample time for the time series</param>
        /// <param name="Differencing">If true the difference between subsequent samples is used in the analysis, rather than the values themselves.</param>
        /// <param name="DeadPeriod">If a gap greater than this is encountered in processing the time series, the fifos will be cleared and refilled when data starts again. Set to an empty string to disable this feature.</param>
        /// <param name="Interpolation">Determine interpolation. values, "interpolate" or blank. </param>
        /// <param name="Name">A name to identify the time series.</param>
        /// <remarks>Resets the analysed state of the time series to false and the embedding parameters to 1.</remarks>
        [WebMethod(Description = "Update the properties of an existing time series.")]
        public void UpdateTimeSeries(string UserID, string SeriesID, string TradingTimesID, string SampleTime, bool Differencing, string DeadPeriod, string Interpolation, string Name)
        {

        }

        /// <summary>
        /// Create a new trading time definition and retrieve its ID.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="TradingEnd">The end of the trading day, relative to the time series data</param>
        /// <param name="TradingStart">The start of the trading day, relative to the time series data</param>
        /// <param name="TwentyFourHrs">If true signifies twenty four hour trading.</param>
        /// <param name="SundayTrade">If true, signifies Sundays are trading days.</param>
        /// <param name="MondayTrade">If true, signifies Mondays are trading days.</param>
        /// <param name="TuesdayTrade">If true, signifies Tuesdays are trading days.</param>
        /// <param name="WednesdayTrade">If true, signifies Wednesdays are trading days.</param>
        /// <param name="ThursdayTrade">If true, signifies Thursdays are trading days.</param>
        /// <param name="FridayTrade">If true, signifies Fridays are trading days.</param>
        /// <param name="SaturdayTrade">If true, signifies Saturdays are trading days.</param>
        /// <returns>The ID by which this trading time definition is subsequently identified</returns>
        [WebMethod(Description = "Create a new trading time definition and retrieve its ID.")]
        public string CreateTradingTimes(string UserID, long TradingEnd, long TradingStart, bool TwentyFourHrs, bool SundayTrade, bool MondayTrade, bool TuesdayTrade, bool WednesdayTrade, bool ThursdayTrade, bool FridayTrade, bool SaturdayTrade)
        {
            return string.Empty;
        }
        /// <summary>
        /// Add holidays, (non-trading days) for use with a trading times definition.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="TradingTimesID">The ID of the trading times object to associate these dates with.</param>
        /// <param name="Holidays">A list of holidays</param>
        [WebMethod(Description = "Add holidays, (non-trading days) for use with a trading times definition.")]
        public void AddHolidays(string UserID, string TradingTimesID, DateTime[] Holidays)
        {
        }
        /// <summary>
        /// Delete the holidays (non-trading days) associated with a trading times definition.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="TradingTimesID">The ID of the trading times object the holidays are associated with.</param>
        [WebMethod(Description = "Delete the holidays (non-trading days) associated with a trading times definition.")]
        public void DeleteHolidays(string UserID, string TradingTimesID)
        {
        }

        /// <summary>
        /// Delete a time series, along with any stored samples.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to delete</param>
        [WebMethod(Description = "Delete a time series, along with any stored samples.")]
        public void DeleteTimeSeries(string UserID, string SeriesID)
        {
        }

        /// <summary>
        /// Analyze the selected time series, and generate the various measures.
        /// </summary>
        /// <remarks>The associated time series is marked as analysed, and the embedding parameters are associated with it for future processing.</remarks>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to analyze</param>
        /// <returns>The results of the analysis.</returns>
        [WebMethod(Description = "Analyze the selected time series, and generate the various measures.")]
        public AnalysisResults Analyze(string UserID, string SeriesID)
        {
            AnalysisResults results = new AnalysisResults();

            return results;
        }


        /// <summary>
        /// Create iterated predictions from the given series.
        /// </summary>
        /// <remarks>Exceptions are thrown if the time series is not marked as analyzed, and the start time 
        /// is later than the last sample in the temporal database.
        /// Iterated predictions are created using the sample time set when the time series was created.
        /// No data in the temporal database before (StartTime - AttentionSpan) will be used to generate predictions.</remarks>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to predict</param>
        /// <param name="predictions">The number of iterated predictions to generate</param>
        /// <param name="StartTime">The time at which to start predictions (see remarks)</param>
        /// <param name="AttentionSpan">The amount of history to use in the predictions</param>
        /// <returns>The predictions</returns>
        [WebMethod(Description = "Create iterated predictions from the given series.")]
        public PredictionResult[] Predict(string UserID, string SeriesID, int predictions, DateTime StartTime, string AttentionSpan)
        {
            PredictionResult[] predictionResults = null;
            return predictionResults;
        }

        /// <summary>
        /// Create iterated predictions from the given series after the most recent sample using all of the stored history.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to predict</param>
        /// <param name="predictions">Number of predictions.</param>
        /// <returns>The predictions</returns>
        /// <remarks>Creates predictions based on the sample time associated with the series. So, for instance if the sample time is one day, and the last data item is for Monday this week at 12:00, if you request 3 predictions you will get predictions for Tuesday at 12:00, Wednesday at 12:00 and Thursday at 12:00. The entire history will be used.</remarks>
        [WebMethod(Description = "Create iterated predictions from the given series after the most recent sample using all of the stored history.")]
        public PredictionResult[] PredictSimple(string UserID, string SeriesID, int predictions)
        {
            return Predict(UserID, SeriesID, predictions, DateTime.MaxValue, string.Empty);
        }


        /// <summary>
        /// Get a list of the existing series owned by this user.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <returns>A list of the series details.</returns>
        [WebMethod(Description = "Get a list of the existing series owned by this user")]
        public SeriesInfo[] GetExistingSeries(string UserID)
        {
            List<SeriesInfo> infos = new List<SeriesInfo>();
            return infos.ToArray();
        }


        /// <summary>
        /// Get the number of sample in a selected series.
        /// </summary>
        /// <param name="UserID">The user's ID, available at http://www.scientio.com </param>
        /// <param name="SeriesID">The ID of the time series to view</param>
        /// <returns>The number of samples</returns>
        [WebMethod(Description = "Get the number of sample in a selected series.")]
        public int GetSeriesLength(string UserID, string SeriesID)
        {
            return 0;
        }


    }
}
